/* eslint valid-jsdoc: "off" */
const { Database } = require('../project.config');
require('@babel/register');


/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = (appInfo) => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = (exports = {});

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1585130561324_6301';

  // add your middleware config here
  config.middleware = ['responseOption', 'statusRespose', 'isLogin', 'ipCheck'];

  config.security = {
    csrf: {
      enable: false,
      ignoreJSON: true,
    },
  };

  config.cors = {
    origin: '*',
    credentials: true,
    allowMethods: 'GET,POST,PUT,DELETE',
  };
  // jwt token加密
  config.jwt = {
    secret: '12WmA)3aI_=%bc!@#',
  };
  // bcrypt 密码加密
  config.bcrypt = {
    saltRounds: 10,
  };

  config.sequelize = {
    dialect: 'mysql',
    host: Database.host,
    port: Database.port,
    database: Database.database,
    username: Database.username,
    password: Database.password,
    define: {
      underscored: true,
      underscoredAll: true,
      freezeTableName: true,
    },
    timezone: '+08:00',
    timestamps: true,
    paranoid: true,
  };

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  return {
    ...config,
    ...userConfig,
  };
};
